module.exports =
  /******/
  (function (modules) { // webpackBootstrap
    /******/ // The module cache
    /******/
    var installedModules = {};
    /******/
    /******/ // The require function
    /******/
    function __webpack_require__(moduleId) {
      /******/
      /******/ // Check if module is in cache
      /******/
      if (installedModules[moduleId]) {
        /******/
        return installedModules[moduleId].exports;
        /******/
      }
      /******/ // Create a new module (and put it into the cache)
      /******/
      var module = installedModules[moduleId] = {
        /******/
        i: moduleId,
        /******/
        l: false,
        /******/
        exports: {}
        /******/
      };
      /******/
      /******/ // Execute the module function
      /******/
      modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
      /******/
      /******/ // Flag the module as loaded
      /******/
      module.l = true;
      /******/
      /******/ // Return the exports of the module
      /******/
      return module.exports;
      /******/
    }
    /******/
    /******/
    /******/ // expose the modules object (__webpack_modules__)
    /******/
    __webpack_require__.m = modules;
    /******/
    /******/ // expose the module cache
    /******/
    __webpack_require__.c = installedModules;
    /******/
    /******/ // define getter function for harmony exports
    /******/
    __webpack_require__.d = function (exports, name, getter) {
      /******/
      if (!__webpack_require__.o(exports, name)) {
        /******/
        Object.defineProperty(exports, name, {
          enumerable: true,
          get: getter
        });
        /******/
      }
      /******/
    };
    /******/
    /******/ // define __esModule on exports
    /******/
    __webpack_require__.r = function (exports) {
      /******/
      if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
        /******/
        Object.defineProperty(exports, Symbol.toStringTag, {
          value: 'Module'
        });
        /******/
      }
      /******/
      Object.defineProperty(exports, '__esModule', {
        value: true
      });
      /******/
    };
    /******/
    /******/ // create a fake namespace object
    /******/ // mode & 1: value is a module id, require it
    /******/ // mode & 2: merge all properties of value into the ns
    /******/ // mode & 4: return value when already ns object
    /******/ // mode & 8|1: behave like require
    /******/
    __webpack_require__.t = function (value, mode) {
      /******/
      if (mode & 1) value = __webpack_require__(value);
      /******/
      if (mode & 8) return value;
      /******/
      if ((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
      /******/
      var ns = Object.create(null);
      /******/
      __webpack_require__.r(ns);
      /******/
      Object.defineProperty(ns, 'default', {
        enumerable: true,
        value: value
      });
      /******/
      if (mode & 2 && typeof value != 'string')
        for (var key in value) __webpack_require__.d(ns, key, function (key) {
          return value[key];
        }.bind(null, key));
      /******/
      return ns;
      /******/
    };
    /******/
    /******/ // getDefaultExport function for compatibility with non-harmony modules
    /******/
    __webpack_require__.n = function (module) {
      /******/
      var getter = module && module.__esModule ?
        /******/
        function getDefault() {
          return module['default'];
        } :
        /******/
        function getModuleExports() {
          return module;
        };
      /******/
      __webpack_require__.d(getter, 'a', getter);
      /******/
      return getter;
      /******/
    };
    /******/
    /******/ // Object.prototype.hasOwnProperty.call
    /******/
    __webpack_require__.o = function (object, property) {
      return Object.prototype.hasOwnProperty.call(object, property);
    };
    /******/
    /******/ // __webpack_public_path__
    /******/
    __webpack_require__.p = "";
    /******/
    /******/
    /******/ // Load entry module and return exports
    /******/
    return __webpack_require__(__webpack_require__.s = 0);
    /******/
  })
/************************************************************************/
/******/
([
  /* 0 */
  /***/
  (function (module, exports, __webpack_require__) {
    "use strict";
    /* eslint-disable */
    // 小程序开发api接口工具包，https://github.com/gooking/wxapi
    let subDomain = '' // 子域名,没有就等于''
    const API_BASE_URL = 'https://plat.echo-isoftstone.cn'
    // const API_BASE_URL = 'http://10.64.80.81:10002'
    // const API_BASE_URL = 'http://10.64.81.165:10002'

    let page = null

    var request = function request(url, needSubDomain, method, data, isBuffer) {
      var _url = API_BASE_URL + url;
      let header = {
        'Content-Type': 'application/json'
      }
      if (wx.getStorageSync('appToken')) header.appToken = wx.getStorageSync('appToken')
      if (wx.getStorageSync('miniAppRole')) header.miniAppRole = wx.getStorageSync('miniAppRole')
      return new Promise(function (resolve, reject) {
        wx.request({
          url: _url,
          method: method,
          data: data,
          responseType: isBuffer ? 'arraybuffer' : '',
          header: header,
          success: (request) => {
            if (request.data.code == 401 && !url.includes('/platform/miniappcard/wx/login')) {
              wx.showToast({
                icon: 'error',
                title: "登录过期",
                duration: 2000,
                success(res) {
                  wx.clearStorageSync()
                  wx.login({
                    success(res) {
                      let nowPage = getCurrentPages()[getCurrentPages().length - 1]
                      wx.setStorageSync('code', res.code)
                      if (nowPage.route == 'pages/card/main') {
                        page.initData()
                      } else {
                        setTimeout(function () {
                          wx.switchTab({
                            url: '/pages/card/main',
                          })
                        }, 2000)

                      }
                    }
                  })
                }
              })
            } else {
              resolve(request.data);
            }

          },
          fail: (error) => {
            reject(error);
          },
          complete: function complete(aaa) {
            // 加载完成
          }
        });
      });
    };

    /**
     * 小程序的promise没有finally方法，自己扩展下
     */
    Promise.prototype.finally = function (callback) {
      var Promise = this.constructor;
      return this.then(function (value) {
        Promise.resolve(callback()).then(function () {
          return value;
        });
      }, function (reason) {
        Promise.resolve(callback()).then(function () {
          throw reason;
        });
      });
    };

    module.exports = {

      init2: function init2(a, b) {
        API_BASE_URL = a;
        subDomain = b;
      },
      init: function init(b) {
        subDomain = b;
      },
      initPage: function initPage(data) {
        page = data
      },
      request: request,
      //备用名片-查询公司下的全部
      getStandbyListCompany: function (companyId) {
        return request('/platform/miniappcard/cardStandbyUser/list/' + companyId, false, 'get')
      },
      //备用名片-查询指定人员的备用名片
      getStandbyUser: function (userId) {
        return request('/platform/miniappcard/cardStandbyUser/' + userId, false, 'get')
      },

      //备用名片-修改指定人员的备用名片
      setStandbyUser: function (userId, data) {
        return request('/platform/miniappcard/cardStandbyUser/' + userId, false, 'post', data)
      },

      //检查是否白名单
      getCardCustomerOwnerStatus: function (phoneNum) {
        return request('/platform/miniappcard/cardCustomerOwner/status?phoneNum=' + phoneNum, false, 'get')
      },
      //申请白名单
      apply: function (data) {
        return request('/platform/miniappcard/cardCustomerOwner/apply', false, 'post', data)
      },
      //重新申请白名单
      reApply: function (data) {
        return request('/platform/miniappcard/cardCustomerOwner/reApply', false, 'post', data)
      },
      //查询公司信息、政策、通知
      getCompanyDif: function getCompanyDif(query) {
        return request('/platform/miniappcard/cardCompanyDif/listById', false, 'get', query);
      },
      //查询顶部轮播
      getBanner: function getBanner(query) {
        return request('/platform/miniappcard/cardCompanyDif/banner', false, 'get', query);
      },
      //查询他人信息
      getVisitCard: function getVisitCard(visitedId) {
        return request('/platform/miniappcard/visit/' + visitedId, false, 'get');
      },
      //登录
      login_wx: function login_wx(data) {
        return request('/platform/miniappcard/wx/login', false, 'post', data);
      },
      //查询个人信息
      getUserInfo: function getUserInfo(data) {
        return request('/platform/miniappcard/wx', false, 'get', data);
      },
      //查询公司信息
      getCompanyById: function getCompanyById(id) {
        return request('/platform/miniappcard/cardCompany/getById?id=' + id, false, 'get');
      },
    };

  })
]);